package com.tianzeculture.stagebao.activity.personal.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tianzeculture.stagebao.R;

import java.util.List;

/**
 * Created by Administrator on 2018/6/19 0019.
 */

public class JobAdapter extends BaseAdapter {
    Context context;
    List<String> jobs;

    public JobAdapter(Context context, List<String> jobs) {
        this.context = context;
        this.jobs = jobs;
    }

    @Override
    public int getCount() {
        return jobs.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.item_job, null);
            holder.tvJob = view.findViewById(R.id.tvJob);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        setData(holder, i);
        return view;
    }

    private void setData(ViewHolder holder, int i) {
        holder.tvJob.setText(jobs.get(i));
    }

    private class ViewHolder {
        TextView tvJob;
    }
}
